package com.shop2cn.iapi.agentproducts.testcase;

import com.shop2cn.iapi.agentproducts.parameter.CategoryListBean;
import com.shop2cn.iapi.agentproducts.service.CategoryListCall;
import com.ymatou.iapi.dglogin.service.SellerRegisterCall;
import com.ymatou.iapi.godmch.parameter.createmchBean;
import com.ymt.core.tool.Logger;
import com.ymt.utils.annotation.TestCase;
import com.ymt.utils.annotation.TestSuite;
import com.ymt.utils.tag.P1;
import com.ymttest.business.service.DGUserCallService;
import com.ymttest.business.service.shenqi.GodmchManageCallService;

import org.junit.*;
import org.junit.experimental.categories.Category;

/**
*类目列表
*FreeMaker Template自动生成代码
*/
@TestSuite
public class Ts_CategoryList{
	private static CategoryListBean categorylistBean;
	private static CategoryListCall categorylistCall;
	@BeforeClass
	public static void setUp() {
		Logger.createResultFile("类目列表");
	}

	@Before
	public void caseUp() {
		categorylistBean=new CategoryListBean();
		categorylistCall=new CategoryListCall();
	}

	@AfterClass
	public static void tearDown() {
		Logger.generateResult(categorylistCall.getOpurl());
	}

	@After
	public void caseDown() {
		Logger.end();
	}
	@Test
	@Category({P1.class})
	@TestCase
	public void Tc_CategoryList_01() {//业务校验
		Logger.start(true,"类目列表,不传父级类目id");
		try {
			SellerRegisterCall dfseller = DGUserCallService.regDefSellerRegister();
			String accessToken=dfseller.getString("accessToken");
			Integer mchid=Integer.valueOf(dfseller.getString("userId"));
			createmchBean createmchbean2 = GodmchManageCallService.InitcreatemchBeanForChannel(mchid);
			GodmchManageCallService.createmchCallForChannel(createmchbean2);
			categorylistCall.setData(categorylistBean);
			categorylistCall.addHeader("ymt-pars","accesstoken="+accessToken);
			categorylistCall.callService();
			Logger.verifyEquals("201",categorylistCall.getString("code"),"验证code");
			Logger.verifyEquals("请求头ymt-pars 不能为空！",categorylistCall.getString("message"),"验证message");

		} catch (Exception e) {
			Logger.fail(e);
		}
	}

}